package com.company.project.vo.resp;

import lombok.Data;

@Data
public class Response<T> {
    private int code; // 状态码，200 表示成功，其他表示失败
    private String message; // 返回消息
    private T data; // 返回数据

    public Response() {}

    public Response(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Response<T> success(T data) {
        return new Response<>(200, "Success", data);
    }

    public static <T> Response<T> success(String message, T data) {
        return new Response<>(200, message, data);
    }

    public static <T> Response<T> error(String message) {
        return new Response<>(500, message, null);
    }

}
